//格式转换工具类
package com.sy.util;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.sy.bean.Point;

public class PointConverter2 extends StrutsTypeConverter {

	@SuppressWarnings("unchecked")
	public Object convertFromString(Map context, String[] values, Class toClass) {
		Point point=new Point();
		String[] paramValues=values[0].split(",");
		int x=Integer.parseInt(paramValues[0]);
		int y=Integer.parseInt(paramValues[1]);
		point.setX(x);
		point.setY(y);
		return point;
	}

	@SuppressWarnings("unchecked")
	public String convertToString(Map context, Object o) {
		Point point=(Point)o;
		int x=point.getX();
		int y=point.getY();
		String result="[x="+x+",y="+y+"]";
		return result;
	}

}
